<?php
//更新对用模块缓存

namespace app\admin\middleware;

class UpdateCacheAfter
{
    /**
     * @param $request
     * @param \Closure $next
     * Desc: 生成对应的model层的缓存数据
     * User: 苏鹏
     * Date: 2023/9/22
     * Time: 20:50
     * @return mixed
     */
    public function handle($request, \Closure $next)
    {
        $response = $next($request);
        // 找到对应的model层去更新数据
        $controller = $request->controller();
        $modelName = 'app\\admin\\model\\'.$controller;
        $model = new $modelName();
        $model->getAdminModelCache('set');

        return $response;
    }
}